package com.java.comprehensive.design.open;

import lombok.Getter;
import lombok.Setter;

public class Animal_OpenClosePrinciple {
    public static void main(String[] args) {
        Animal catC = new Cat();
        catC.setSex("公");
        catC.getKind();

        Animal dogC = new Dog();
        dogC.setSex("母");
        dogC.getKind();

    }
}

@Getter
@Setter
abstract class Animal {
    private String sex;

    public abstract void getKind();

}

class Dog extends Animal {
    @Override
    public void getKind() {
        System.out.println("小狗\t" + super.getSex());
    }
}

class Cat extends Animal {
    @Override
    public void getKind() {
        System.out.println("猫咪\t" + super.getSex());
        System.out.println();
    }
}
